package com.atguigu01._static.apply;

/**
 * ClassName: PersonTest
 * Description:
 *   自动给id赋值的基数
 * @Author liu
 * @Create 2024/11/1 10:41
 * @Version 1.0
 */
public class circleTest {
    public static void main(String[] args) {
            Circle c1 = new Circle();
            System.out.println(c1);

            Circle c2 = new Circle(2.0);
            System.out.println(c2);

            Circle c3= new Circle();
            System.out.println(c3);

            Circle c4 = new Circle(5.0);
            System.out.println(c4);

        System.out.println(Circle.total);
    }


}
class Circle{
    double radius;//半径

    int id;//编号

    static int total;//实例个数

    static int init = 1001;//自动给id赋值的基数
    public Circle(){
        this.id = init;
        init++;//处于静态域内，单独保存
        total++;
    }

    public Circle(double radius) {
        this();//用于调用其他的构造器
        this.radius = radius;
    }

    @Override
    public String toString() {
        return "Circle{" +
                "radius=" + radius +
                ", id=" + id +
                '}';
    }
}
